'''
Created on Mar 21, 2016

@author: JimmyMo
'''

from dispatchmethod import DispatchMethod

import time
import schedule

class DispatchMethod_Timer(DispatchMethod):
    def __init__(self, interval):
        super(DispatchMethod_Timer, self).__init__()
        self.interval = interval
    def set_method_target(self, target):
        self.target = target
        self.method_to_run = target.dispatch_to
    def dispatch(self):
        schedule.every(self.interval).seconds.do(self.method_to_run)
#         schedule.run_all(delay_seconds=0);
#         while 1:
#             schedule.run_pending()
#             time.sleep(1)